﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Fang.Common
{
    public partial class EntertoTabFrm : Form
    {
        public EntertoTabFrm()
        {
            InitializeComponent();
        }
        /// <summary> 
        /// 键盘处理事件 
        /// 主要实现的功能是重写键盘命令事件。使用户在使用的时候，如果当前焦点不是在Button(按钮)上的话，就可以用Enter代替Tab键了。 
        /// </summary> 
        /// <param name="msg"></param> 
        /// <param name="keyData"></param> 
        /// <returns></returns> 
        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            if ((!(ActiveControl is Button)) && (keyData == Keys.Up || keyData == Keys.Down || keyData == Keys.Enter))
            {
                if (keyData == Keys.Enter)
                {
                    System.Windows.Forms.SendKeys.Send("{TAB}");
                    return true;
                }
                if (keyData == Keys.Down)
                    System.Windows.Forms.SendKeys.Send("{TAB}");
                else
                    SendKeys.Send("+{Tab}");
                return true;
            }
            else
                return base.ProcessCmdKey(ref msg, keyData);
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
